/*
    异步 echo server, 并简化粘包处理流程
    添加逻辑线程处理网络收到的任务
    服务器优雅的关闭
*/

#include "server.h"

int main(void)
{
    try
    {
        boost::asio::io_context io;
        
        boost::asio::signal_set signals(io, SIGINT, SIGTERM);
        signals.async_wait([&](auto, auto){
            std::cout << "Server is going to shutdown" << std::endl;
            io.stop();  
        });

        Server server(io, 12345);
        io.run();
    }
    catch (const std::exception& e)
    {
        std::cout << "Exception: " << e.what() << std::endl;
        return 1;
    }

    return 0;
}